﻿using QDPay.code;
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QDPay
{
    public partial class frmMain : FormBase
    {
        public frmMain()
        {
            InitializeComponent();
            lblVersion.Text = Application.ProductVersion.ToString();
            FormBase.SetMainForm(this);
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            Init();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            OpenForm(new frmLogin());
        }

        private void btnPay_Click(object sender, EventArgs e)
        {
            if (Session.StoreEmployee != null)
                OpenForm(new frmPay());
            else
                btnLogin_Click(sender, e);
        }

        void Init()
        {
            var user = Session.StoreEmployee;
            if (user != null)
            {
                lblStatus.Text = "已登录";
                lblUserName.Text = user.LoginName;
                lblStoreName.Text = user.StoreName;
            }
        }

        private void frmMain_Activated(object sender, EventArgs e)
        {
            Init();
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

    }
}
